﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<QianBuo.Lottery.Web.Models.PlayTypeModel>" %>

<body >
    <div id="play_inputpanel">
        <table border="0" cellpadding="0" cellspacing="5" class="play_play_input">
            <tr>
                <td>
                   &nbsp; 
                </td>
                <td colspan="10" align="left">
                    <input type="radio" name="inputtype" checked="checked" value="0" id="inputtype_mouse"/><label for="inputtype_mouse">鼠标选择(复式)</label> 
                    <input type="radio" name="inputtype" value="1" id="inputtype_hand"/><label for="inputtype_hand">手工输入(单式)</label> 
                </td>
            </tr>
            <tr class="tr_number" id="p10000">
                <td class="head">万位</td>
                <td class="number">0</td>
                <td class="number">1</td>
                <td class="number">2</td>
                <td class="number">3</td>
                <td class="number">4</td>
                <td class="number">5</td>
                <td class="number">6</td>
                <td class="number">7</td>
                <td class="number">8</td>
                <td class="number">9</td>
                <td>
                    &nbsp;
                </td>
                <td class="tool">全</td>
                <td class="tool">大</td>
                <td class="tool">小</td>
                <td class="tool">奇</td>
                <td class="tool">偶</td>
                <td class="tool">清</td>
            </tr>
            <tr class="tr_number" id="p1000">
                <td class="head">千位</td>
                <td class="number">0</td>
                <td class="number">1</td>
                <td class="number">2</td>
                <td class="number">3</td>
                <td class="number">4</td>
                <td class="number">5</td>
                <td class="number">6</td>
                <td class="number">7</td>
                <td class="number">8</td>
                <td class="number">9</td>
                <td>
                    &nbsp;
                </td>
                <td class="tool">全</td>
                <td class="tool">大</td>
                <td class="tool">小</td>
                <td class="tool">奇</td>
                <td class="tool">偶</td>
                <td class="tool">清</td>
            </tr>
            <tr class="tr_number" id="p100">
                <td class="head">百位</td>
                <td class="number">0</td>
                <td class="number">1</td>
                <td class="number">2</td>
                <td class="number">3</td>
                <td class="number">4</td>
                <td class="number">5</td>
                <td class="number">6</td>
                <td class="number">7</td>
                <td class="number">8</td>
                <td class="number">9</td>
                <td>&nbsp;</td>
                <td class="tool">全</td>
                <td class="tool">大</td>
                <td class="tool">小</td>
                <td class="tool">奇</td>
                <td class="tool">偶</td>
                <td class="tool">清</td>
            </tr>
            <tr>
                <td colspan="8" id="sumcount">
                    注数:<font color="red">0</font>
                </td>
                <td colspan="10" align="left">
                    <input type="button" name="bet_play_btnadd" onclick="QianSanZhiXuan.addScheme()" id="bet_play_btnadd" value="添加" class="bet_play_btnadd" />
                </td>
            </tr>
        </table>
            
        <script type="text/javascript">
           
            $(".play_play_input .number").click(function () {
                var item = $(this);
                var id = item.parent().attr("id");
                if (item.is(".select")) {
                    item.removeClass("select");
                    QianSanZhiXuan.ChooseNumber[id] = QianSanZhiXuan.ChooseNumber[id].replace(item.text(),'');
                }
                else {
                    item.addClass("select");
                    QianSanZhiXuan.ChooseNumber[id] = QianSanZhiXuan.ChooseNumber[id] + item.text();
                }

                //alert(QianSanZhiXuan.ChooseNumber['p10000'].length+','+QianSanZhiXuan.ChooseNumber['p1000'].length+','+QianSanZhiXuan.ChooseNumber['p100'].length);

                var count = QianSanZhiXuan.ChooseNumber['p10000'].length * QianSanZhiXuan.ChooseNumber['p1000'].length * QianSanZhiXuan.ChooseNumber['p100'].length;

                $(".play_play_input #sumcount font").html(count);
            });

            QianSanZhiXuan={};

            $(".play_play_input .tool").click(function () {
                QianSanZhiXuan.selectNumber($(this).parent().find(".number"), this.innerText);
            });

            QianSanZhiXuan.ChooseNumber=[];

            QianSanZhiXuan.ChooseNumber['p10000'] = '';
            QianSanZhiXuan.ChooseNumber['p1000'] = '';
            QianSanZhiXuan.ChooseNumber['p100'] = '';

            QianSanZhiXuan.PlayID=<%=Model.ID %>;
            QianSanZhiXuan.PlayName='<%=Model.Name%>';
            QianSanZhiXuan.PlayTypeListID=<%=Model.PlayTypeListID %>;
            
            Site.Lottery.Bet.SetCurrentPlay(QianSanZhiXuan.PlayID, QianSanZhiXuan.PlayName);
            Site.Lottery.Bet.CurrentPlay.PlayTypeID=QianSanZhiXuan.PlayTypeListID;
            

            QianSanZhiXuan.addScheme=function() {
                for (var n in QianSanZhiXuan.ChooseNumber) {
                    if (QianSanZhiXuan.ChooseNumber[n].length == 0) {
                        alert('号码选择不正确！');
                        return;
                    }

                    QianSanZhiXuan.ChooseNumber[n] = QianSanZhiXuan.ChooseNumber[n].split('').sort().join('');
                }

                var number = QianSanZhiXuan.ChooseNumber['p10000'] + ',' + QianSanZhiXuan.ChooseNumber['p1000'] + ',' + QianSanZhiXuan.ChooseNumber['p100'];
                var count = QianSanZhiXuan.ChooseNumber['p10000'].length * QianSanZhiXuan.ChooseNumber['p1000'].length * QianSanZhiXuan.ChooseNumber['p100'].length;
        
                if(Site.Lottery.Bet)
                    Site.Lottery.Bet.AddPlayItem(QianSanZhiXuan.PlayID,QianSanZhiXuan.PlayName,QianSanZhiXuan.PlayTypeListID,number,count,1)

                QianSanZhiXuan.ChooseNumber['p10000'] = '';
                QianSanZhiXuan.ChooseNumber['p1000'] = '';
                QianSanZhiXuan.ChooseNumber['p100'] = '';
                $(".play_play_input #sumcount font").html('0');
                $(".play_play_input .tool:contains('清')").click();
            }

            QianSanZhiXuan.selectNumber=function(numbers, type) {

                numbers.each(function () {
                    $(this).removeClass("select");
                });
                QianSanZhiXuan.ChooseNumber[numbers.parent().attr("id")]='';
                $(".play_play_input #sumcount font").html('0');
        
                switch (type) {
                    case "全":
                        numbers.click();
                        break;
                    case "大":
                        numbers.each(function () {
                            if (parseInt(this.innerText) > 4)
                                $(this).click();
                        });
                        break;
                    case "小":
                        numbers.each(function () {
                            if (parseInt(this.innerText) < 5)
                                $(this).click();
                        });
                        break;
                    case "奇":
                        numbers.each(function () {
                            if (parseInt(this.innerText) % 2 ==1)
                                $(this).click();
                        });
                        break;
                    case "偶":
                        numbers.each(function () {
                            if (parseInt(this.innerText) % 2 ==0)
                                $(this).click();
                        });
                        break;
                }

            }

        </script>
    </div>
</body>


